home *** CD-ROM | disk | FTP | other *** search
- /************************************************/
- /* Sample DLL's */
- /* Copyright © Vincent Parsons 1989. */
- /************************************************/
- /* DLL code for MPW C 3.0 or THINK C 4.0 */
- /* with Excel for the Macintosh 2.2 */
- /* and Microsoft C 5.1 */
- /* with Excel for Windows 2.1 */
- /************************************************/
- /* SampMem is an example of using memory */
- /* management to save a value from one */
- /* execution of a DLL to the next */
- /************************************************/
- /* =REGISTER("SampDLLs","SampMem","JIJ") */
- /* Macintosh only. */
- /************************************************/
-
- #include "DLL.h"
-
- typedef long * LongPtr;
-
- #if applec
- #include <Types.h>
- #include <Memory.h>
-
- #endif
-
- #if THINK_C
- pascal unsigned long main(short opcode, unsigned long u1); /* prototype */
-
- pascal unsigned long main(opcode, u1)
- short opcode;
- unsigned long u1;
-
- #elif applec
- pascal unsigned long SampMem(short opcode, unsigned long u1)
-
- #endif
- {
- unsigned long tempLong;
- unsigned long result;
-
- switch (opcode) {
- case 0:
- result = (unsigned long)NewHandle(4);
- *((LongPtr)(*((Handle)result))) = u1;
- break;
- case 1:
- tempLong = *((LongPtr)(*((Handle)u1)));
- tempLong++;
- *((LongPtr)(*((Handle)u1))) = tempLong;
- result = tempLong;
- break;
- case 2:
- DisposHandle((Handle)u1);
- result = 0;
- break;
- default:
- result = 0;
- break;
- }
- return ( result );
- }
-
- /************************************************/
-